package generics;

import java.util.ArrayList;
import java.util.List;

public class Test {

	
	public static void main(String[] args) {
		List<Animal> animalList = new ArrayList<Animal>(2);
		addAnimal(animalList);
		List<Dog> dogs = new ArrayList<Dog>(2);
		addAnimal(dogs);
		checkAnimal(dogs);
	}

	private static void addAnimal(List<? super Dog> list) {
		list.add(new Dog());		
	}

	private static void checkAnimal(List<? extends Animal> list) {
		for (Animal a : list){
			a.voice();
		}
	}
	
	
	
}

class Animal {
	public void voice() {
	};
}

class Dog extends Animal {
	public void voice() {
	};
}